
echo "Start nav2 code"   

SCRIPT_DIR=$(pwd)
source /opt/ros/humble/setup.bash     #注意版本为humble
source $SCRIPT_DIR/install/setup.bash
source /usr/share/gazebo/setup.sh

ps -ef | grep gazebo | awk '{print $2}' | xargs kill -9   #把上次残留的gazebo进程杀掉

 commands=(
"gnome-terminal -- bash -c ' ros2 launch fishbot_description gazebo.launch.py ; exec bash;'"
"sleep 1"
"gnome-terminal -- bash -c ' ros2 launch fishbot_navigation2 navigation2.launch.py use_sim_time:=True ; exec bash;'"
)


for command in "${commands[@]}"; do
  
  eval "$command"

done


# 开始运行机器人的导航节点代码
sleep 2
ctime=$(date +"%Y-%m-%d_%H-%M-%S")
file_name="output/${ctime}.log"  #因为实车导航中，我们需要知道机器人具体作出什么导航决策，所以把终端输出保存起来。因为这里是仿真，不需要的保存的话自行去掉
gnome-terminal -- bash -c "ros2 run fishbot_decision decision > ${file_name} 2>&1; exec bash;"



